/**
 * 功能描述
 */
define(function (require, exports, module) {
    //引入视图基类
    var ELView = require("elview");
    var aw = require("ajaxwrapper");
    
    //assets
    var template = require("./assets/tpl/changeroom_main.tpl");
    require("./assets/css/changeroom_main.css");
    //events
    var roomPanoramaHandler = require("./handler/roomSelectHandler");
    var gridHandler = require("./handler/gridHandler");

    //component
    var changeRoomSubnavComp = require("./component/changeRoomSubnavComp");
    var changeRoomGridComp = require("./component/changeRoomGridComp");
    var changeRoomForm = require("./component/changeRoomForm");
    var changeRoomEditGridComp = require("./component/changeRoomEditGridComp");
    var changeRoomDetailGridComp = require("./component/changeRoomDetailGridComp");
    var checkoutRoomFormComp = require("./component/checkoutRoomFormComp");
    var roomConsumpEditGrid = require("./component/roomConsumpEditGrid");
    var damagesConsumpEditGrid = require("./component/damagesConsumpEditGrid");
    var roomConsumpDetailGrid = require("./component/roomConsumpDetailGrid");
    var damagesConsumpDetailGrid = require("./component/damagesConsumpDetailGrid");

    var changeroom_main = ELView.extend({
        attrs: {
            template: template,
            model:{
        		flag:"ExchangeRoom"
        	}
        },
        events: roomPanoramaHandler.events,
        gridHandler: gridHandler,
        changeImg: roomPanoramaHandler.changeImg,
        print: roomPanoramaHandler.print,
        setData: roomPanoramaHandler.setData, //设置房型选择列表data
        renderRoomNumber: roomPanoramaHandler.renderRoomNumber,
        setRoomPersonInfo: roomPanoramaHandler.setRoomPersonInfo,
        roomStateConfirm: roomPanoramaHandler.roomStateConfirm,
        selectPersonInfo: roomPanoramaHandler.selectPersonInfo,
        showRooms: roomPanoramaHandler.showRooms,
        selectRoom:roomPanoramaHandler.selectRoom,
        initComponent: function (params, widget) {
        	changeRoomSubnavComp.initComponent(params, widget);
        	changeRoomGridComp.initComponent(params, widget);
        	changeRoomForm.initComponent(params, widget);
        	changeRoomEditGridComp.initComponent(params, widget);
        	changeRoomDetailGridComp.initComponent(params, widget);
        	checkoutRoomFormComp.initComponent(params, widget);
        	roomConsumpEditGrid.initComponent(params, widget);
        	damagesConsumpEditGrid.initComponent(params, widget);
        	roomConsumpDetailGrid.initComponent(params, widget);
        	damagesConsumpDetailGrid.initComponent(params, widget);
        },
        afterInitComponent: function (params, widget) {
        	aw.ajax({
				url:"api/baseprice/getprice",
				dataType:"json",
				success:function(data){
					widget.set("baseprice",data);
					widget.get("grid").refresh();
				}
			});
        }
    });

    module.exports = changeroom_main;
});
